import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GangFightsMagicStoneCellRenderer } from "./cellRenderer/GangFightsMagicStoneCellRenderer";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { FontUtil } from "../../../common/font/FontUtil";
import { GImageBitmap } from "../../../../com/mui/controls/GImageBitmap";
import { BaseItem } from "../common/BaseItem";
import { ItemData } from "../../resource/info/ItemData";
import { Cache } from "../../cache/Cache";
import { SGangFightsMyInfoEx } from "../../../../Message/Public/SGangFightsMyInfoEx";
import { GangFightsMagicStoneData } from "./data/GangFightsMagicStoneData";
import { GTileList } from "../../../../com/mui/controls/GTileList";
//class GangFightsMagicStoneWindow
    
    export  class GangFightsMagicStoneWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(514, 433);
            title = Language.getString(44560);
            titleHeight = 26;
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc7=null;
            super.createChildren();
            this.initDataArray();
            setSize(247, 258);
            ObjCreate.createBg(18, 38, 247, 260, this);
            ObjCreate.createBg(269, 38, 227, 260, this);
            ObjCreate.createBg(18, 301, 478, 120, this);
            ObjCreate.createTextField(Language.getString(44561), 50, 51, 70, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(44562), 182, 51, 70, 20, this, GlobalStyle.textFormat6);
            this._tileList = ObjCreate.createTileList(34, 73, 224, 217, this);
            this._tileList.rowHeight = 31;
            this._tileList.columnWidth = 224;
            this._tileList.setStyle("cellRenderer", GangFightsMagicStoneCellRenderer);
            this._tileList.dataProvider = new DataProvider(this._magicStoneDataArray);
            var loc1=GlobalStyle.textFormatGreen;
            loc1.size = 14;
            loc1.bold = true;
            this._tfDate = ObjCreate.createTextField(Language.getString(44563), 315, 75, 150, 20, this, loc1);
            ObjCreate.createTextField(Language.getString(44564), 310, 117, 90, 20, this);
            ObjCreate.createTextField(Language.getString(44565), 310, 150, 90, 20, this);
            var loc2=GlobalStyle.textFormat6;
            loc2.font = FontUtil.EmbedNumberName;
            loc2.size = 25;
            this._tfLastScore = ObjCreate.createEmbedTextFiled("0", 402, 114, 80, 25, this, loc2);
            this._tfLastMagicStone = ObjCreate.createEmbedTextFiled("0", 402, 147, 80, 25, this, loc2);
            var loc3=ObjCreate.createTextField("", 305, 208, 170, 20, this, GlobalStyle.textFormatGreen);
            loc3.htmlText = Language.getString(44566);
            var loc4;
            (loc4 = GlobalStyle.textFormat1).leading = 7;
            var loc5;
            (loc5 = ObjCreate.createTextField("", 299, 238, 184, 40, this, loc4)).wordWrap = true;
            loc5.multiline = true;
            loc5.text = Language.getString(44567);
            this.addChild(new GImageBitmap("GangFightsMagicStoneExcPrize.png", 38, 311));
            var loc6=0;
            while (loc6 < this._prizeItemCodeArray.length) 
            {
                ObjCreate.createBg(37 + 75 * loc6, 340, 64, 64, this);
                (loc7 = new BaseItem()).itemData = new ItemData(int(this._prizeItemCodeArray[loc6]));
                loc7.x = 39 + 75 * loc6;
                loc7.y = 342;
                loc7.width = 60;
                loc7.height = 60;
                this.addChild(loc7);
                ++loc6;
            }
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            var loc1=Cache.instance.gangFights.myInfoEx;
            var loc2=Cache.instance.gangFights.account;
            if (loc1) 
            {
                this.updateInfoEx(loc1);
            }
            return;
        }

        public updateInfoEx(arg1: SGangFightsMyInfoEx): void
        {
            this._tfLastScore.text = arg1.lastTeamMarkDay.toString();
            this._tfLastMagicStone.text = arg1.lastMagicStone.toString();
            return;
        }

        /* internal  */initDataArray(): void
        {
            this._magicStoneDataArray = [];
            this._magicStoneDataArray.push(new GangFightsMagicStoneData("8000~11999", "70~90"));
            this._magicStoneDataArray.push(new GangFightsMagicStoneData("12000~13999", "90~100"));
            this._magicStoneDataArray.push(new GangFightsMagicStoneData("14000~15999", "120~130"));
            this._magicStoneDataArray.push(new GangFightsMagicStoneData("16000~17999", "150~160"));
            this._magicStoneDataArray.push(new GangFightsMagicStoneData("18000~19999", "180~190"));
            this._magicStoneDataArray.push(new GangFightsMagicStoneData("20000~25000", "210~235"));
            this._prizeItemCodeArray = [14117301, 14117401, 14126001, 14126101, 14031189, 14031190];
            return;
        }

        public static hasInstance(): Boolean
        {
            return !(GangFightsMagicStoneWindow._instance == null);
        }

        public static get instance(): GangFightsMagicStoneWindow
        {
            if (!GangFightsMagicStoneWindow._instance) 
            {
                GangFightsMagicStoneWindow._instance = new GangFightsMagicStoneWindow();
            }
            return GangFightsMagicStoneWindow._instance;
        }

        /* internal */ /* var */_magicStoneDataArray: Array<any>;

        /* internal */ /* var */_prizeItemCodeArray: Array<any>;

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_tfDate: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLastScore: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLastMagicStone: Object /* flash.text.TextField */;

        /* internal */ static /* var */_instance: GangFightsMagicStoneWindow;
    }
